//
//  Hold.m
//  singlebreath
//
//  Created by Eric van Riet Paap on 26-09-08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "Hold.h"


@implementation Hold

@synthesize	begin, end;


-(id)initWithBegin:(float)_begin end:(float)_end {
	self.begin = _begin;
	self.end   = _end;
	return self;
}


+(id)holdWithBegin:(float)_begin end:(float)_end {
	return [[[Hold alloc] initWithBegin:_begin end:_end] retain];
}


+(NSMutableArray*)addArrayWithRepeats:(NSMutableArray*)holds initial_recovery:(float)initial_recovery repeat:(int)repeat hold:(float)hold recovery:(float)recovery {
	float	cur_time = 0.0;
	if (holds.count) {
		cur_time = [[holds objectAtIndex:[holds count] - 1] end];
	}
	cur_time += initial_recovery;

	while (repeat-- > 0) {		
		[holds addObject:[Hold holdWithBegin:cur_time end:cur_time + hold]];
		cur_time += hold + recovery;
	}
	return holds;
}


@end
